import { createAxios } from '@/utils/http/axios';

enum Api {
  updateById = '/virtual/iotVirtualDevice/updateById',
  updateKeepOnlineNum = '/virtual/iotVirtualDevice/updateKeepOnlineNum',
}

export interface IotVirtualDevice {
  id?: number;
  sn?: string;
  pn?: string;
  imei?: string;
  productId?: number;
  protocolId?: number;
  keepOnline?: 0 | 1;
  deviceStatus?: string;
  lat?: string;
  lng?: string;
  uploadCron?: string;
  warnHexStr?: string;
  warnBitList?: [];
}

export function updateVirtualDeviceByIdApi(data: IotVirtualDevice) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post({
    url: Api.updateById,
    data: data,
  });
}

export function updateKeepOnlineNumApi(data: { num: number }) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post({
    url: Api.updateKeepOnlineNum,
    data: data,
  });
}
